package wiimote;

import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote;
import wiiusej.wiiusejevents.utils.WiimoteListener;

public class WiimoteLink {
	public static Wiimote peripherique;

	public static void connect(){
		Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
		if (wiimotes[0] != null){
			peripherique = wiimotes[0];
			peripherique.setLeds(true, false, false, true);
		}
	}

	public static boolean connected(){
		return peripherique != null;
	}
	public static void disconnect(){
		if (connected())
			peripherique.disconnect();

	}
	public static void addWiiRemoteListener(WiimoteListener listener){
		if (connected()){
			peripherique.addWiiMoteEventListeners(listener);
		}
	}
	public static void removeWiiRemoteListener(WiimoteListener listener){
		if (connected())
			peripherique.removeWiiMoteEventListeners(listener);
	}

}
